{extend name="public/base"/}
{block name="body"}
<title>添加/修改 - 设置 -</title>
<style type="text/css">
	.isshow{display:block;}
	.disshow{display:none;}
</style>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span>设置管理<span class="c-gray en">&gt;</span> 设置 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<article class="page-container">
	<form class="form form-horizontal" id="form-admin-add">
		<input type="hidden" class="input-text" value="{$data.id}" id="id" name="id">
		<!-- <div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">积分：</label>
			<div class="formControls col-xs-8 col-sm-9">
               <label class="radio-inline">
                   <input type="radio" id="emailwy1" name="invite_fix_scale" value="1" {if $data['invite_fix_scale']==1}checked{/if} />
                   <label for="emailwy1">固定</label>
               </label>
               <label class="radio-inline">
                   <input type="radio" id="emailwy2" name="invite_fix_scale" value="2" {if $data['invite_fix_scale']==2}checked{/if} />
                   <label for="emailwy2">比例</label>
               </label>
			</div>
		</div> -->
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">邀请积分：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="{$data.invite_score}" id="invite_score" name="invite_score">
				<p id="qiniu1" class="{if $data.invite_fix_scale==1}isshow{elseif $data.invite_fix_scale==2}disshow{/if}" style="font-size:10px;color:#999;">每买一个产品，邀请者获取固定n积分</p>
				<p id="qiniu2" class="{if $data.invite_fix_scale==2}isshow{elseif $data.invite_fix_scale==1}disshow{/if}" style="font-size:10px;color:#999;">1元=n积分；(邀请的下线，每有一个购买套餐花费1元得n积分)</p>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">抵消积分：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="{$data.buy_score}" id="buy_score" name="buy_score">
				<p style="font-size:10px;color:#999;">购买套餐产品,1元=n积分(n个积分可以抵消1元人民币)</p>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">提现积分：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="{$data.withdraw_score}" id="withdraw_score" name="withdraw_score">
				<p style="font-size:10px;color:#999;">提现时,1元=n积分(n个积分可以换算成1元人民币)</p>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">最低提现金额：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="{$data.withdraw_money_min}" id="withdraw_money_min" name="withdraw_money_min">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">积分规则：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<script id="editor" name="score_rule" type="text/plain" style="width:100%;height:400px;">{:htmlspecialchars_decode($data.score_rule)}</script>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">提现规则：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<script id="withdraw_rule" name="withdraw_rule" type="text/plain" style="width:100%;height:400px;">{:htmlspecialchars_decode($data.withdraw_rule)}</script>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">平台介绍：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<script id="editor_introduce" name="introduce" type="text/plain" style="width:100%;height:400px;">{:htmlspecialchars_decode($data.introduce)}</script>
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-3 col-sm-offset-2">
				<input id="submit" class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</article>
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/static/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="/static/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="/static/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="/static/lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" src="/static/lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
<script type="text/javascript" src="/static/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
$(function(){
	var ue = UE.getEditor('editor');
	var ue = UE.getEditor('withdraw_rule');
	var ue = UE.getEditor('editor_introduce');
  $("#emailwy1").on('click',function(){
	$("#qiniu2").removeClass('isshow');
	$("#qiniu2").addClass('disshow');
	$("#qiniu1").removeClass('disshow');
	$("#qiniu1").addClass('isshow');
	$("#emailwy2").attr('checked', false);
	$(this).attr('checked', true);
  });
  $("#emailwy2").on('click',function(){
	$("#qiniu1").removeClass('isshow');
	$("#qiniu1").addClass('disshow');
	$("#qiniu2").removeClass('disshow');
	$("#qiniu2").addClass('isshow');
	$("#emailwy1").attr('checked', false);
	$(this).attr('checked', true);
  });
});
$("#submit").click(function() {
	layer.load(1, {
	  shade: [0.1,'#fff'] //0.1透明度的白色背景
	});
	var invite_fix_scale=$("input[name=invite_fix_scale][checked]").val();
	var invite_score=$("input[name=invite_score]").val();
	var buy_score=$("input[name=buy_score]").val();
	var withdraw_score=$("input[name=withdraw_score]").val();
	var withdraw_money_min=$("input[name=withdraw_money_min]").val();
	var score_rule=UE.getEditor('editor').getContent();
	var withdraw_rule=UE.getEditor('withdraw_rule').getContent();
	var introduce=UE.getEditor('editor_introduce').getContent();
    $.ajax({
	    type: 'POST',
	    url: "{:url('system_set')}",
	    data: {invite_fix_scale:invite_fix_scale,invite_score:invite_score,buy_score:buy_score,withdraw_score:withdraw_score,withdraw_money_min:withdraw_money_min,withdraw_rule:withdraw_rule,score_rule:score_rule,introduce:introduce},
	    success: function(resdata){
	        if(resdata.code==200){
				layer.msg(resdata.msg,{icon:1,time:1000});
				setTimeout("location.reload()",1000);
	        }else{
				layer.msg(resdata.msg,{icon:2,time:3000});
	        }
	    },
	    error: function(){
			layer.msg('数据保存失败',{icon:2,time:3000});
	    }
	})
})
</script> 
{/block}